Page({
  data:{
    "password":"",
    "password2":"",
    "password3":""
  },
  password1_FN:function(e){
    this.data.password=e.detail.value;
  },
  password2_FN:function(e){
    this.data.password2=e.detail.value;
    if(this.data.password2!=this.data.password3&&this.data.password3!=""){
      wx.showModal({
        "title":"提示",
        "content":"两次输入密码不一致",
        "showCancel":false
      })
    }
  },
  password3_FN:function(e){
    this.data.password3=e.detail.value;
    if(this.data.password2!=this.data.password3&&this.data.password3!=""){
      wx.showModal({
        "title":"提示",
        "content":"两次输入密码不一致",
        "showCancel":false
      })
    }
  },
  sure_FN:function(){
    console.log(wx.getStorageSync("user_name"),this.data.password,this.data.password2)
    var self=this;
    if(this.data.password==""){
      wx.showModal({
        "title":"提示",
        "content":"请输入原密码",
        "showCancel":false
      })
      return;
    }else if(this.data.password2==""){
      wx.showModal({
        "title":"提示",
        "content":"请输入新密码",
        "showCancel":false
      })
      return;
    }else if(this.data.password3==""){
      wx.showModal({
        "title":"提示",
        "content":"请再次输入新密码",
        "showCancel":false
      })
      return;
    }else if(this.data.password2!=this.data.password3&&this.data.password3!=""){
      wx.showModal({
        "title":"提示",
        "content":"两次输入密码不一致",
        "showCancel":false
      })
      return;
    }
    wx.showLoading();
    wx.request({
      url:"https://wx.ichelaba.com/htapi/index.php/user/user/savePassword",
      data:{
        user_name:wx.getStorageSync("user_name"),
        password:self.data.password,
        new_password:self.data.password2
      },
      method:"GET",
      success:function(res){
        wx.hideLoading();
        if(res.data.result){
          wx.showToast({
            "title":"修改成功",
            "mack":true,
            "complete":function(){
              wx.reLaunch({
                url:"/pages/list/list"
              })
            }
          })
        }else{
          wx.showModal({
            "title":"提示",
            "content":res.data.message,
            "showCancel":false
          })
        }
      }
    })
  }
})